
<template>
	<div id="app-shopXq">
			<!--头部按钮-->
			<img src="../img-shopXq/icon_backH@3x.png" class="backH topbtnH"/>
			<span id="backbtn" class="topbtn" @click="back()">
				<img src="../img-shopXq/icon_back@3x.png"/>
			</span>
			<img src="../img-shopXq/icon_grzxH@3x.png" class="grzxH topbtnH"/>
			<span id="user-zx" class="topbtn" @click="grzx()">
				<img src="../img-shopXq/icon_grzx@3x.png"/>
			</span>
			<!--底部按钮-->
			<div class="shopxq-bottom-btn" v-if="member_status!=1">
				<ul>
					<li><router-link to="/"><img src="http://liangzhong.oss-cn-hangzhou.aliyuncs.com/newwap/shangpin/icon_shouye@2x.png" alt="" /><p>首页</p></router-link></li>
					<li><router-link :to="user==0?{path:'/login'}:{path:'/informationshi',query:{'goodsid':shopid}}"><img src="http://liangzhong.oss-cn-hangzhou.aliyuncs.com/newwap/shangpin/kefu.png" alt="" /><p>客服</p></router-link></li>
					<li><router-link to="/shopping"><img src="http://liangzhong.oss-cn-hangzhou.aliyuncs.com/newwap/shangpin/gwccc.png" alt="" /><p>购物车</p></router-link></li>
				</ul>
				<span class="jrshopcart shuangbtn" @click="guigexianshi(1)">加入购物车</span>
				<span class="ljgm shuangbtn" @click="guigexianshi(2)">立即购买</span>
				<div class="ljfdingjin" v-show="djysShow" @click="tixing()">
					<p>立即购买</p>
				</div>
				<div class="ljfdingjins" style="display: none;">
					<p>商品已下架</p>
				</div>
				<button class="julikaishou" v-show="xsksShow"><p>距离开售</p><span>3 天 22 时 30 分 59 秒 </span></button>
			</div>
			<div class="shopxq-bottom-btn-shangjia" v-if="member_status==1">
				<ul>
					<li @click="deleteshop"><i><img src="../img-shopXq/icon_del@3x.png"/></i><span>删除</span></li>
					<li @click="shangxiajia(false)" v-if="if_show==1"><i><img src="../img-shopXq/icon_xia@3x.png"/></i><span>下架</span></li>
					<li @click="shangxiajia(true)" v-if="if_show==0"><i><img src="../img-shopXq/icon_shang@3x.png"/></i><span>上架</span></li>
					<li @click="shoparea"><i><img src="../img-shopXq/icon_edit@3x.png"/></i><span>编辑</span></li>
				</ul>
			</div>
			<!-- Swiper -->
		    <div class="swiper-container shopxq-swiper-container">
		        <div class="swiper-wrapper">
		            <div class="swiper-slide" v-for="item in shopimg"><img :src="'http://www.ntyouxuan.com/'+item"/></div>
		        </div>
		        <!-- Add Pagination -->
		        <div class="swiper-pagination"></div>
		    </div>
		    <!--定金预售-->
		    <div class="dingjinHD dingjinHDxx" style="display: none;">
		    	<img src="../img-shopXq/bg2018.png"/>
		    	<div class="dingjinHD-xinxi xsyouhui-xinxi">
		    		<p class="kaisheng">距开售还剩：</p>
		    		<p class="countdown1"><span class="xsyh-t1" v-text="tianshu"></span>天<span class="xsyh-x1" v-text="xiaoshi"></span>小时<span class="minutes" v-text="fenzhong"></span>分<span class="seconds" v-text="miao"></span>秒</p>
		    	</div>
		    </div>
		    <!--shop信息-->
		    <div class="shopxinxi">
		    	<div class="shoucangBtn" v-show="favrite==0" @click="shoucang()">
		    		<img src="../img-shopXq/icon_like_OFF@3x.png"/>
		    		<p>加入收藏</p>
		    	</div>
		    	<div class="shoucangBtn" v-show="favrite==1"  @click="yishoucang()">
		    		<img src="../img-shopXq/icon_like_ON@3x.png"/>
		    		<p>已收藏</p>
		    	</div>
		    	<h3 v-text="shopxinxi.goods_name"></h3>
		    	<p class="jiage" >
		    		<span>￥</span>
		    		<span style="font-size: 0.4rem;" v-text="shopxinxi.price"></span>
		    	</p>
		    	<div class="fujiaxinxi">
		    		运费
		    		<span v-text="shopxinxi.region_area"></span>
		    		<span></span>
		    		<span style="float: right;" v-text="shopxinxi.region_name"></span>
		    	</div>
		    	<div class="fujiaxinxi" v-show="shuaxl">已售出：<span v-text="xiaoliang"></span></div>
		    </div>
		    <!--推广模块-->
		    <ul class="tgxinxi" v-if="userStute==1">
		    	<li>推广佣金</li>
		    	<li class="yongjin">
		    		￥<span v-text="shopxinxi.commission"></span>
		    	</li>
		    	<li class="xstkxx" @click="xstkbox()"><img src="http://liangzhong.oss-cn-hangzhou.aliyuncs.com/newwap/shangpin/tuiguang.png"/><p>立即推广</p></li>
		    </ul>
		    <!--选择规格-->
		    <div class="guigexuanze" @click="guigexianshi(0)">
		    	<span>选择规格</span>
		    	<img src="../img-shopXq/icon_next@3x.png"/>
		    	<span class="guigexinxi" v-text="xzyi+'  '+erjixz"></span>
		    </div>
		    <!--店铺链接跳转-->
		    <div class="shopname">
		    	<span v-text="shopxinxi.store_name"></span>
		    	<router-link :to="{path:'/business/shopindex',query:{'store':shopxinxi.store_id}}">进入店铺<img src="../img-shopXq/icon_next@3x.png"/></router-link>
		    </div>
		    <!--详情-->
		    <div class="xqtop-box" id="xqtop-box">
		    	<ul class="xqtop" id="xqtop">
		    		<li :class="{'active':pjisxq}" @click="pjisxqbtn(true)">详情</li>
		    	</ul>
		    </div>
		    <!--详情模块-->
		    <div id="kong" v-if="!pjisxq">
				<img class="kong-img" src="../img-shopping/pic@2x.png"/>
				<p class="kong-p">这里没有任何评价呢</p>
			</div>
		   	<shopxqy v-show="pjisxq" :msg='xqxinxi'></shopxqy>
		    <!--评价模块-->
		    <shoppj v-if="!pjisxq" :msg="shopid"></shoppj>
		    <!--弹出框模块-->
		    <div class="fixmodul" v-show="guigeShow" >
		    	<div @click="guanbitanchuang" style="width: 100%;height:190px;background-color:rgba(0,0,0,0.4);"></div>
		    	<div class="shopguige">
		    		<div class="shopguige-topxinxi">
		    			<span class="guanbi" @click="guanbi()"><img src="../img-shopXq/icon_close@2x.png"/></span>
		    			<img :src="'http://www.ntyouxuan.com/'+shopxinxi.default_image"/>
		    			<h3 class="xsyh-xxx">￥{{guigeMoney}}</h3>
		    			<p>库存量 {{guigeKc}} 件</p>
		    		</div>
		    		<div class="xuanziguoge-xzk">
			    		<div class="guigeyangshi" v-show="shopxinxi.spec_name_1">
			    			<h4>请选择{{shopxinxi.spec_name_1}}</h4>
			    			<span v-for="item in guigeyiarr" v-text="item" @click="gGxz(item,1)" :class="{'active':xzyi==item}"></span>
			    		</div>
			    		<div class="guigeyangshi" v-show="shopxinxi.spec_name_2">
			    			<h4>请选择{{shopxinxi.spec_name_2}}</h4>
			    			<span v-for="item in guigeerarr" v-text="item" @click="gGxz(item,2)" :class="{'active':erjixz==item}"></span>
			    		</div>
			    		<div class="guigenum">
			    			<span class="xsyh-btt">选择购买数量</span>
			    			<div>
			    				<span class="jian" @click="jian()"><i></i></span>
			    				<span class="num" v-text="gouwuNum" contenteditable="true"></span>
			    				<span class="jia" @click="jia()"><img src="../img-shopXq/icon_jia@3x.png"/></span>
			    			</div>
			    		</div>
		    		</div>
		    		
		    		<button class="quedinganniu" @click="shopqueding()">确&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;定</button>
		    	</div>
		    </div>
		    <!--佣金推广模块弹出层-->
		    <div class="fixmodul1" v-show="tgboxShow">
		    	<div class="tuiguangmodil">
		    		<span class="tuiguang_guanbi" @click="guanbi()"><img src="../img-shopXq/guanbi@3x.png"/></span>
		    		<h3>推&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;广</h3>
		    		<p>朋友通过你的分享页面成功购买后，可获得对应的佣金</p>
		    		<ul>
		    			<li @click="wxfxfun()"><img src="../img-shopXq/icon_weixin@3x.png"/><p>微信</p></li>
		    			<li @click="ewmfxfun()"><img src="../img-shopXq/icon_code@3x.png"/><p>二维码</p></li>
		    			<li @click="twewmfxfun()"><img src="../img-shopXq/icon_text@3x.png"/><p>图文二维码</p></li>
		    		</ul>
		    		<h4>预计可赚取佣金<span v-text="'￥ '+shopxinxi.commission"></span></h4>
		    	</div>
		    </div>
		    <div class="wx-fenxiang fenxiang" v-show="wxfx" @click="wxfx=false">
		    	<img src="../img-shopXq/jiantou@3x.png"/>
		    	<p>点击<span>右上角</span>分享给朋友</p>
		    	<p>朋友下单成功</p>
		    	<p>即可获得佣金</p>
		    </div>
		    <div class="fenxiang ewmfenxiang" v-show="ewmfxshow">
		    	<span @click="ewmfxshow=false"><img src="../img-shopXq/icon_close@3x.png"/></span>
		    	<img :src="'http://www.ntyouxuan.com/index.php?app=default&act=goods_QR&id='+shopid+'&token='+user"/>
		    	<p>长按保存至相册</p>
		    	<img src="../img-shopXq/hand@3x.png"/>
		    </div>
		    <div class="fenxiang twewmfenxiang" v-show="twewmshow">
		    	<span @click="twewmshow=false"><img src="../img-shopXq/icon_close@3x.png"/></span>
		    	<img :src="'http://www.ntyouxuan.com/index.php?app=default&act=goods_detail&id='+shopid+'&token='+user"/>
		    </div>
		    <deletctr :msg="deletemsg" @btnstatus="deletebtn" v-show="deleteshow"></deletctr>
		</div>
</template>

<script>
	import shopXQcss from '../css/shopXQ.css';
	import layercss from "../css/layer.css"
	import layerjs from "../js/layer.js"
	import shopxqy from '@/components/shopxq/shopxqpage'
	import deletctr from "@/components/widget/deletectrol"
	import wx from 'weixin-js-sdk'
	import djscj from '../js/jquery.downCount.js';
	
	var furl = 'http://www.ntyouxuan.com/';
	export default {
		name:"shopXQ",
		data () {
			return {
				user:0,
				curl:0,
				userStute:0,
				scroll:'',
				scrollH:"",
				shopxinxi:"",
				shopimg:[],
				shopguige:{},
				pjisxq:true,
				xsyhShow:true,
				xsyhShowend:true,
				xsksShow:false,
				xsyhXinxi:{},
				xsdjxinxi:{},
				shopid:"",
				gouwuNum:1,
				tgboxShow:false,
				guigeShow:false,
				guigeyiarr:[],
				guigeerarr:[],
				xqxinxi:"",
				xzyi:"",
				zhxz:"",
				erjixz:"",
				guigezhuangtai:"",
				shopScrollWatch:true,
				wxfx:false,
				ewmfxshow:false,
				twewmshow:false,
				favrite:0,
				swipershop:"",
				guigeMoney:"",
				guigeKc:"",
				fa_btime:"",
				fa_etime:'',
				ad_etime:'',
				fullcut:'',
				timeff:'',
				fullcuts:true,
				wxdata:{
					'appid':'',
					'timestamp':'',
					'wxnonceStr':'',
					'wxShal':'',
					'title':'',
					'title_desc':'',
					'link':'',
					'img_url':'',
				},
				aurl:'',
				member_status:0,
				if_show:0,
				btns:'',
				deletemsg:'',
				deleteshow:false,
				show: true,
				count: '',
				timer: null,
				messages:'',
				djysShow:false,
				shuaxl:false,
				xiaoliang:'',
				tianshu:'',
				xiaoshi:'',
				fenzhong:'',
				miao:''
			}
		},
		components:{shopxqy,deletctr},
		methods:{
			isWeiXin() {
		      let ua = window.navigator.userAgent.toLowerCase();
		      //mozilla/5.0 (iphone; cpu iphone os 9_1 like mac os x) applewebkit/601.1.46 (khtml, like gecko)version/9.0 mobile/13b143 safari/601.1
		      if (ua.match(/MicroMessenger/i) == 'micromessenger') {
		      return true;
		      } else {
		      return false;
		      }
		    },
			menu:function(){
				if(this.shopScrollWatch){
					var self=this;
					this.scroll = document.getElementById("xqtop-box").offsetTop;
					this.scrollH =document.body.scrollTop ||  document.documentElement.scrollTop;
					var pofH = this.scroll-this.scrollH;
					var opacityNum=1-(self.scrollH/self.scroll);
					$(".topbtn").css("opacity",opacityNum>0.6? 0.6:opacityNum);
					$(".topbtnH").css("opacity",1-opacityNum);
					if(pofH<=0){
						$("#xqtop").css({"position":"fixed","top":"0","left":"0"});
					}else{
						$("#xqtop").css({"position":"relative","top":"0","left":"0"});
					}
				}
				
			},
			pjisxqbtn:function(sta){
				this.pjisxq=sta;
				var self=this;
				if(this.scrollH>=this.scroll){
					$(window).scrollTop(self.scroll);
				}else{
					$(window).scrollTop(self.scrollH);
				}
				
			},
			shopxq:function(){
				var self=this;
		        $.ajax({
		        	type:"get",
		        	url:furl+'index.php?app=ajax_goods&act=goods_description',
		        	data:{"id":self.shopid},
		        	dataType:"json",
		        	success:function(res){
		        		self.xqxinxi=res.retval.description;
		        	}
		        });
			},
			back:function(){	
				history.go(-1);
			},
			xstkbox:function(){
				this.tgboxShow=true;
			},
			guanbi:function(){
				this.tgboxShow=false;
				this.guigeShow=false;
			},
			guanbitanchuang:function(){
				this.tgboxShow=false;
				this.guigeShow=false;
			},
			guigexianshi:function(num){
				this.guigezhuangtai=num;
				//根据状态来判断规格页面的确定键是加入购物车还是立即购买
				this.guigeShow=true;
			},
			tixing:function(){
				layer.open({
					content: '未开售',
					skin: 'msg',
					time: 2 
				});
			},
			shopqueding:function(){
				this.gouwuNum = $(".num").text()
				/*---------------------------------------*/
				if(this.gouwuNum>this.xsyhxgnum&&this.xsyhxgnum!=0){ 
					layer.open({
						content: '超出限购数量',
						skin: 'msg',
						time: 2 
					});
					return;
				}
				var self=this;
				if(this.guigezhuangtai==0){
					this.guigeShow=false;
				}
				if(this.guigezhuangtai==1){
					if(this.zhxz){
						$.ajax({
							type:"post",
							url:furl+"index.php?app=ajax_cart&act=add_cart",
							data:{'spec_id':self.zhxz,'quantity':self.gouwuNum,'token':self.user,'curl':self.curl},
							dataType:"json",
							success:function(res){
								console.log(res);
								if(res.retval.status==1){
									layer.open({
									    content: '添加购物车成功'
									    ,skin: 'msg'
									    ,time: 2 //2秒后自动关闭
									});
									console.log("添加购物车成功");
									self.guigeShow=false;
								}
							}
						});
					}else{
						console.log("请选择规格");
						layer.open({
						    content: '请选择规格'
						    ,skin: 'msg'
						    ,time: 2 //2秒后自动关闭
						});
					}
				}
				if(self.user==0){
				 	layer.open({
				    	content: '请登陆后购买'
				    	,btn: ['取消','确定']
				    	,yes: function(index){
				      		window.location.href = 'http://www.ntyouxuan.com/newnt/#/login';
				      		layer.close(index);
				    	}
				  	});
				}
				if(this.guigezhuangtai==2){
					if(this.zhxz){
						console.log(this.zhxz,this.user,this.gouwuNum);
						$.ajax({
							type:"post",
							url:furl+"index.php?app=ajax_cart&act=add_cart",
							data:{'spec_id':self.zhxz,'quantity':self.gouwuNum,'token':self.user,'curl':self.curl},
							dataType:"json",
							success:function(res){
								if(res.retval.status==1){
									self.$router.push({path:'/shopDd',query:{'god':self.shopid,'did':self.shopxinxi.store_id,'gidg':self.zhxz}});
								}
								
							}
						});
					}else{
						layer.open({
						    content: '请选择规格'
						    ,skin: 'msg'
						    ,time: 3 //2秒后自动关闭
						});
						console.log("请选择规格");
					}
				}else{
					console.log("请先登录再添加购物车");
				}
			},
			zLarr:function(){
				var guigearr1=[];
				var guigearr2=[];
				//对后台传入的规格数据进行处理，生成两个数组来显示规格信息；
				var i=0;
				for(var key in this.shopguige){
					guigearr1[i]=this.shopguige[key].spec_1;
					guigearr2[i]=this.shopguige[key].spec_2;
					i++;
				}
				this.guigeyiarr=guigearr1.unique3();
				this.guigeerarr=guigearr2.unique3();
			},
			jian:function(){
				if(this.gouwuNum>1){
					$(".jia").removeClass("jia1");
					this.gouwuNum--;
				}else{
					$(".jian").removeClass("jian1");
				}
				
			},
			jia:function(){
				if(this.gouwuNum<99){
					$(".jian").addClass("jian1");
					this.gouwuNum++;
				}else{
					$(".jia").addClass("jia1");
				}
			},
			gGxz:function(item,num){
				if(num==1){
					//num==1时为1级规格选择；2为2级；如果有2级就显示当前选中的二级
					if(this.shopxinxi.spec_name_2){
						var guigexz=[];
						var i=0;
						this.xzyi=item;
						this.erjixz="";
						this.zhxz=""
						for(var key in this.shopguige){
							if(this.shopguige[key].spec_1==item){
								guigexz[i]=this.shopguige[key].spec_2;
								i++;
							}
						}
						this.guigeerarr=guigexz.unique3();
					}else{
						this.xzyi=item;
						for(var key in this.shopguige){
							if(this.shopguige[key].spec_1==item){
								this.zhxz=this.shopguige[key].spec_id;
								this.guigeMoney=this.shopguige[key].price;
								this.guigeKc=this.shopguige[key].stock;
							}
						}
					}
					
				}
				if(num==2){
					if(this.shopxinxi.spec_name_1){
						for(var key in this.shopguige){
							if(this.shopguige[key].spec_2==item&&this.shopguige[key].spec_1==this.xzyi){
								console.log(this.shopguige[key]);
								this.erjixz=item;
								this.zhxz=this.shopguige[key].spec_id;
								this.guigeMoney=this.shopguige[key].price;
								this.guigeKc=this.shopguige[key].stock;
							}
						}
					}else{
						this.erjixz=item;
						for(var key in this.shopguige){
							if(this.shopguige[key].spec_2==item){
								this.zhxz=this.shopguige[key].spec_id;
								this.guigeMoney=this.shopguige[key].price;
								this.guigeKc=this.shopguige[key].stock;
							}
						}
					}
					
				}
			},
			wxfxfun:function(){
				var self=this;
				this.tgboxShow=false;
				var turl=encodeURIComponent('shopXQ/'+self.shopid+'?curl='+self.user);
	        	self.wxdata.link=furl+"newnt/index.html?url="+turl;
				$.ajax({
					type:"post",
					url:furl+"index.php?app=ajax_third_login&act=wxjssdk",
					data:{'aurl':self.adurl},
					dataType:'json',
					success:function(res){
						if(res.done){
							self.wxdata.appid=res.retval.appid;
							self.wxdata.timestamp=res.retval.timestamp;
							self.wxdata.wxShal=res.retval.wxShal;
							self.wxdata.wxnonceStr=res.retval.wxnonceStr;
							if(self.isWeiXin()){
								self.wxConfig(wx,self.wxdata);
							}
							
						}
					}
				});
				this.wxfx=true;
				this.curl=this.user;
				this.userStute=0;
			},
			ewmfxfun:function(){
				this.tgboxShow=false;
				this.ewmfxshow=true;
			},
			twewmfxfun:function(){
				this.tgboxShow=false;
				this.twewmshow=true;
			},
			shoucang:function(){
				if(this.user!=0){
					this.favrite=1;
					this.shoucangajax();
				}else{
					alert("请先登录");
				}
			},
			yishoucang:function(){
				this.favrite=0;
				this.shoucangajax();
			},
			swiperLun:function(){
				var self=this;
				setTimeout(function(){
					self.swipershop = new Swiper('.swiper-container', {
						pagination: '.swiper-pagination',
						paginationType: 'fraction',
						autoplay:5000,
						slidesPerView:1,
						loop: true,
						autoplayDisableOnInteraction:false,
						stopOnLastSlide:true
					});
				},1000);
			},
			shoucangajax:function(){
				var self=this;
				$.ajax({
					url:furl+"index.php?app=ajax&act=add_goods_json",
					type:"get",
					data:{"item_id":self.shopid,"token":self.user},
					dataType:"json",
					success:function(res){
						console.log(res);
					}
				})
			},
			deleteshop:function(){
				this.btns=1;
				this.deletemsg='你确定要<span>删除</span>该商品吗？';
				this.deleteshow=true;
			},
			shangxiajia:function(stu){
				this.btns=2;
				if(stu){
					this.deletemsg='你确定要<span>上架</span>该商品吗？';
				}else{
					this.deletemsg='你确定要<span>下架</span>该商品吗？';
				}
				this.deleteshow=true;
			},
			shoparea:function(){
				this.$router.push({path:'/business/shoparea',query:{'spid':this.shopid}});
			},
			grzx:function(){
				this.$router.push({path:'/user'});
			},
			deletebtn:function(data){
				if(this.btns==1){
					if(data){
						var self=this;
						$.ajax({
							type:"post",
							url:furl+"index.php?app=ajax_seller_member&act=drop_goods",
							data:{'token':self.user,'goods_id':self.shopid},
							dataType:'json',
							success:function(res){
								if(res.done){
									self.deleteshow=false;
									history.go(-1);
								}
							}
						});
					}else{
						this.deleteshow=false;
					}
				}
				if(this.btns==2){
					if(data){
						var self=this;
						$.ajax({
							type:"post",
							url:furl+"index.php?app=ajax_seller_member&act=ajax_col_if_show",
							data:{'token':self.user,'goods_id':self.shopid},
							dataType:'json',
							success:function(res){
								if(res.done){
									if(self.if_show==0){
										self.if_show=1
									}else{
										self.if_show=0
									}
									self.deleteshow=false;
								}
							}
						});
					}else{
						this.deleteshow=false;
					}
				}
			}
		},
		created:function(){
			if(this.$route.query.curl){
				this.curl=this.$route.query.curl;
			}else{
				this.curl=0;
			}
			$(window).scrollTop(0);
			if(localStorage.getItem("nt_user")&&localStorage.getItem("nt_stute")){
				this.user=localStorage.getItem("nt_user");
				this.userStute=localStorage.getItem("nt_stute");
				if(this.curl!=0){
					this.userStute=0;
				}
			}
			this.shopid=this.$route.params.id;
			this.aurl=location.href;
		    var self=this;
	        $.ajax({
	        	url:furl+"index.php?app=ajax_goods&act=goods_ajax",
	        	type:"get",
	        	data:{"id":self.shopid,"token":self.user},
	        	dataType:"json",
	        	success:function(res){
	        		self.shopxinxi=res.retval;
	        		self.member_status=res.retval.member_status;
	        		self.if_show=res.retval.if_show;
	        		if (self.if_show == 0) {
	        			$('.shuangbtn').hide();
	        			$('.ljfdingjins').css('display','block')
	        		}
	        		if(res.retval.type_new == 2&&res.retval.type_status == 0) {
	        			$(".dingjinHD3").css('display','block')
	        			self.dejbjtime=res.retval.fullcut.time
	        			var timesstss = Math.floor(Number(self.dejbjtime)/(3600*24)) 
			        	$(".xsyh-ts").text(timesstss)
			        	var timesshsss = Math.floor(Number(self.dejbjtime-(24*3600)*timesstss)/3600) 
			        	$(".xsyh-xs").text(timesshsss)
			        	var timessmss = new Date(Number(self.dejbjtime)*1000).Format('mm')
			        	self.timeff = timessmss;
			        	self.messages = '距离活动结束仅剩'
	        		}
	        		if(res.retval.type_new == 2&&res.retval.type_status == 1) {
	        			$(".dingjinHD3").css('display','block')
	        			self.dejbjtime=res.retval.fullcut.time
	        			var timesstss = Math.floor(Number(self.dejbjtime)/(3600*24)); 
			        	$(".xsyh-ts").text(timesstss);
			        	var timesshsss = Math.floor(Number(self.dejbjtime-(24*3600)*timesstss)/3600);
			        	$(".xsyh-xs").text(timesshsss);
			        	var timessmss = new Date(Number(self.dejbjtime)*1000).Format('mm')
			        	self.timeff = timessmss;
			        	self.messages = '距离活动开始还有'
	        		}
	        		if(res.retval.type_new == 3&&res.retval.type_status == 0) {
						$('.hdtp').attr('src','http://liangzhong.oss-cn-hangzhou.aliyuncs.com/jd2015/default/images/777055079673102664.png')
						$('.hdjxx').hide();
						$('.hdjxxs').hide();
	        		}
	        		if(res.retval.type_new == 3&&res.retval.type_status == 1) {
						$('.hdtp').attr('src','http://liangzhong.oss-cn-hangzhou.aliyuncs.com/jd2015/default/images/777055079673102664.png')
						$('.hdjxx').hide();
						$('.hdjxxs').hide();
						$('#jssj').text('距离活动开始还有');
	        		}
	        		if(res.retval.type_new == 4&&res.retval.type_status == 0) {
						$('.hdtp').attr('src','http://liangzhong.oss-cn-hangzhou.aliyuncs.com/jd2015/default/images/585145383389742449.png')
						$('.hdjxx').hide();
						$('.hdjxxs').hide();
	        		}
	        		if(res.retval.type_new == 4&&res.retval.type_status == 1) {
						$('.hdtp').attr('src','http://liangzhong.oss-cn-hangzhou.aliyuncs.com/jd2015/default/images/585145383389742449.png')
						$('.hdjxx').hide();
						$('.hdjxxs').hide();
						$('#jssj').text('距离活动开始还有');
	        		} 
	        		if(res.retval.type_status)
	        		//分销状态
	        		self.wxdata.img_url=furl+res.retval.default_image;
	        		var turl=encodeURIComponent('shopXQ/'+self.shopid);
	        		self.wxdata.link=furl+"newnt/index.html?url="+turl;
	        		self.wxdata.title='【农淘优选】'+res.retval.goods_name;
	        		self.wxdata.title_desc=res.retval.goods_subname;
	        		
	        		self.favrite=res.retval.favorite;
	        		self.shopimg=res.retval._images;
	        		self.shopguige=res.retval._specs;
					if(!res.retval.spec_name_1&&!res.retval.spec_name_2){
						self.zhxz=res.retval.default_spec;
					}
	        		for(var key in res.retval._specs){	        				
	        			if(res.retval.default_spec==res.retval._specs[key].spec_id){
	        				self.guigeMoney=res.retval._specs[key].price;
	        				self.guigeKc=res.retval._specs[key].stock;
	        				console.log(self.guigeKc);
	        			}
	        		}
//	        		if(res.retval.fullcut){
//	        			//满减
//	        			self.fullcut=res.retval.fullcut;
//	        		}
/*--------------------------------显示倒计时------------------------------------------------------------------*/
	        		Array.prototype.unique3 = function(){
					 	var res = [];
					 	var json = {};
					 	for(var i = 0; i < this.length; i++){
					  		if(!json[this[i]]){
					   			res.push(this[i]);
					   			json[this[i]] = 1;
					  		}
					 	}
					 	return res;
					}
	        		
	        		
	        		self.zLarr();
	        		self.shopxq();
	        		self.swiperLun();
	        	}
	        });
		},
		mounted:function(){
			layer.open({type: 2,time: 0.5});
			$('.countdown').downCount({
				date: '4/03/2029 00:00:00',
				offset: +10
			}, function() {
//				alert('倒计时结束!');
			});
			$('.countdowns').downCount({
				date: '4/03/2029 00:00:00',
				offset: +10
			}, function() {
//				alert('倒计时结束!');
			});
			$('.countdown1').downCount({
				date: '4/03/2029 00:00:00',
				offset: +10
			}, function() {
//				alert('倒计时结束!');
			});
			var self=this;
			
			window.addEventListener("scroll",this.menu);
			this.adurl=location.href;
			$.ajax({
				type:"post",
				url:furl+"index.php?app=ajax_third_login&act=wxjssdk",
				data:{'aurl':self.adurl},
				dataType:'json',
				success:function(res){
					if(res.done){
						self.wxdata.appid=res.retval.appid;
						self.wxdata.timestamp=res.retval.timestamp;
						self.wxdata.wxShal=res.retval.wxShal;
						self.wxdata.wxnonceStr=res.retval.wxnonceStr;
						if(self.isWeiXin()){
							self.wxConfig(wx,self.wxdata);
						}
						
					}
				}
			});
			$.ajax({
	        	url:furl+"index.php?app=ajax_goods&act=goods_ajax",
	        	type:"get",
	        	data:{"id":self.shopid,"token":self.user},
	        	dataType:"json",
	        	success:function(res){
	        		self.tzhuye = res.retval.goods_id
	        		console.log(self.tzhuye);
	        		/*============================*/
	        		if(self.tzhuye==1309){
	        			self.shuaxl = true;
						self.xiaoliang = '3035件';
	        		};
	        		if(self.tzhuye==1319){
	        			self.shuaxl = true;
						self.xiaoliang = '5635件';
	        		};
	        		if(self.tzhuye==1314){
	        			self.shuaxl = true;
						self.xiaoliang = '9817件';
	        		};
	        		if(self.tzhuye==1303){
	        			self.shuaxl = true;
						self.xiaoliang = '1769件';
	        		};
	        		if(self.tzhuye==546){
	        			self.shuaxl = true;
						self.xiaoliang = '3012件';
	        		};
	        		if(self.tzhuye==1295){
	        			self.shuaxl = true;
						self.xiaoliang = '302件';
	        		};
	        		if(self.tzhuye==730){
	        			self.shuaxl = true;
						self.xiaoliang = '634件';
	        		};
	        		if(self.tzhuye==1191){
	        			self.shuaxl = true;
						self.xiaoliang = '263件';
	        		};
	        		if(self.tzhuye==486){
	        			self.shuaxl = true;
						self.xiaoliang = '149件';
	        		};
	        		if(self.tzhuye==854){
	        			self.shuaxl = true;
						self.xiaoliang = '435件';
	        		};
	        		if(self.tzhuye==1327){
	        			self.shuaxl = true;
						self.xiaoliang = '575件';
	        		};
	        		if(self.tzhuye==1326){
	        			self.shuaxl = true;
						self.xiaoliang = '603件';
	        		};
	        		if(self.tzhuye==1324){
	        			self.shuaxl = true;
						self.xiaoliang = '186件';
	        		};
	        		if(self.tzhuye==1298){
	        			self.shuaxl = true;
						self.xiaoliang = '231件';
	        		};
	        		if(self.tzhuye==1322){
	        			self.shuaxl = true;
						self.xiaoliang = '231件';
	        		};
	        		if(self.tzhuye==1326){
	        			self.shuaxl = true;
						self.xiaoliang = '575件';
	        		};
	        		if(self.tzhuye==1327){
	        			self.shuaxl = true;
						self.xiaoliang = '447件';
	        		};
	        		if(self.tzhuye==1320){
	        			self.shuaxl = true;
						self.xiaoliang = '287件';
	        		};
	        		if(self.tzhuye==1315){
	        			self.shuaxl = true;
						self.xiaoliang = '396件';
	        		};
	        		
	        		
	        		
	        		
	        		
	        		
	        		
	        		
	        		
	        		
	        		
	        		
	        		if(res.retval._pro == null){
	        			$("#dl").css("display","none")
	        			$(".dingjinHD1").css("display","none")
	        			self.xsyhShow=false;
	        		}
	        		if(res.retval._pro.restrictions == 1){
	        			$(".xsyh-btt").text("选择购买数量(限购"+res.retval._pro.restrictions+'件)')
	        		}
	        		if(res.retval._pro.status == 1){
	        			self.xsyhXinxi=res.retval._pro;
	        			self.xsyhShow=true;
	        			
		        	    /*限时优惠*/
		        		self.xsyhxj=res.retval._pro.price_all
		        		$(".xsyh-xj").text(self.xsyhxj)
		        		self.xsyhyj=res.retval.price
		        		$(".xsyh-yj").text("原价￥"+self.xsyhyj)
		        		self.xsyhtime=res.retval._pro.times
			        		var timesst = Math.floor(Number(self.xsyhtime)/(3600*24)) 
			        		$(".xsyh-t").text(timesst)
			        		var timessh = Math.floor(Number(self.xsyhtime-(24*3600)*timesst)/3600) 
			        		$(".xsyh-x").text(timessh)
			        		var timessm = new Date(Number(self.xsyhtime)*1000).Format('mm')
//			        		$(".xsyh-f").text(timessm)
			        		var timesss = new Date(Number(self.xsyhtime)*1000).Format('ss') 
//			        		$(".xsyh-m").text(timesss)	
	        		}else{
	        			self.xsyhShow=false;//不显示
	        		}
	        		if(res.retval._pro.status == 0){
	        			self.xsyhxgnum=res.retval._pro.restrictions
	        			self.xsyhXinxi=res.retval._pro;
	        			self.xsyhShowend=true;
	        			
		        	    /*限时优惠*/
		        		self.xsyhxj=res.retval._pro.price_all
//		        		$(".xsyh-xj").text(self.xsyhxj)
		        		self.xsyhyj=res.retval.price
		        		$(".xsyh-yj").text("原价￥"+self.xsyhyj)
		        		self.xsyhtime=res.retval._pro.times
			        		var timesst = Math.floor(Number(self.xsyhtime)/(3600*24)) 
			        		$(".xsyh-t").text(timesst)
			        		var timessh = Math.floor(Number(self.xsyhtime-(24*3600)*timesst)/3600) 
			        		$(".xsyh-x").text(timessh)
			        		var timessm = new Date(Number(self.xsyhtime)*1000).Format('mm')
//			        		$(".xsyh-f").text(timessm)
			        		var timesss = new Date(Number(self.xsyhtime)*1000).Format('ss') 
//			        		$(".xsyh-m").text(timesss)	
						
						/**/
						$(".jiage").text(self.xsyhxj)
						$(".xsyh-xxx").text(self.xsyhxj)
						$(".xsyh-yj").css("display","none")
						$(".xsyh-xj").text("原价"+self.xsyhyj)
						$(".xsyh-xj").css("text-decoration","line-through")
						
	        		}else{
	        			self.xsyhShowend=false;//不显示
	        		}
	        		
	        	}
	        	
	       	});
	       	
	       	
	       	
		},
		updated:function(){
			var self=this;
			
		},
		destroyed:function () {
		    this.shopScrollWatch = false;
		}
	}
</script>

<style>
	#kong{
		text-align: center;
		margin: 0 auto;
		margin-top: 2.2rem;
	}
	#kong img{
		width: 3.6rem;
		height: 3.2rem;
	}
	#kong .kong-p{
		font-size: 0.32rem;
		color: #999999;
		margin-top: 0.84rem;
	}
	#kong .kong-b{
		width: 1.8rem;
		height: 0.7rem;
		border:1px solid #5DB440;
		margin-left:2.85rem;
		margin-top: 0.44rem;
		border-radius: 0.35rem;
	}
	#kong .kong-btn{
		font-size: 0.33rem;
		color: #5DB440;
		line-height: 0.7rem;
	}
</style>